using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;

namespace YayiMgr.Ability.Docking.Commom
{
    public class ResponseDto<T>
    {
        public int Code { get; set; }
        public string Message { get; set; }
        public T Data { get; set; }

        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="message"></param>
        /// <param name="code">100 已知原因的失败；101 未知原因的失败</param>
        /// <returns></returns>
        public static ResponseDto<T> CreateFail(string message, int code = 100)
        {
            return new ResponseDto<T>{Code = code, Message = message };
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static ResponseDto<T> CreateSuccess(T data, string message = "成功")
        {
            return new ResponseDto<T>{Code = 200, Message = message, Data = data };
        }
    }
}